< previous page page_222 next page >

Page 222
Adding a Caption
To add a caption to the InputBox() function, you need to add a second parameter with the value you want to place in the title bar of the input box. See Figure 11.6 for an example of an input box with a caption.
8160-0222a.gif
Figure 11.6
An inputbox with a caption.
I recommend that you always pass in the Caption parameter, because this will help describe the input box. If you do not pass it in, Visual Basic will just use the EXE name for the caption. Heres the code that generates the input box shown in Figure 11.6:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdCaption_Click()
   Dim strName As String

   strName = InputBox("Enter an Employee Name", _
                    "Employee Name")
   MsgBox "You input " & strName
End Sub
Adding a Default Value
You can specify a value that appears in the text box when the input box first appears. Just add the third parameter to the InputBox() function, and that value appears in the text box of the input box. Heres an example:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdDefault_Click()
   Dim strName As String

   strName = InputBox("Enter an Employee Name", _
                      "Employee Name", _
                      "Bill Gates")

   MsgBox "You input " & strName
End Sub

 
< previous page page_222 next page >

If you like this book, buy it!